/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.mvc.helpers
{
	/**
	 * Invoke a function after a while. iHelper instance will help us control this timer. 
	 * @author puny
	 * @see com.puny.mvc.helpers.IHelper
	 */
	public class DelayHelper {
		/**
		 * 
		 * @param delay millisecond that it takes before the main function is invoked.
		 * @param init a function to initialize.
		 * @param fnc a main function which is invoked in <code>delay</code> millisecond.
		 * @param immediately if <code>true</code>, count down starts immediately. Otherwise, invoke <code>IHelper.start()</code> to start counting down.
		 * @return a helpr instance.
		 * 
		 */		
		public static function setup(delay:int,init:Function,fnc:Function,immediately:Boolean=true):IHelper {
			return ContextHelper.getInstance(DelayContext.getInstance(delay,init,fnc),immediately);
		}
		
		/**
		 * Report running delay helpers on console.
		 * 
		 */
		public static function debug():void {
			DelayContext.debug();
		}
		
		public static function cleanup():void {
			DelayContext.clear();
		}
	}
}